package com.woniuxy02;

import java.util.Scanner;

/**
 * @author 作者
 * @create 2025-07-16 14:26
 */
public class Test10 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        //产生一个随机数
        int random= (int) (Math.random()*100);
        System.out.println("random:" + random);
        int num,count=0;
        //flag--true猜对了
        boolean flag=false;
        do{
            count++;
            System.out.println("输入你猜的数字");
            num = sc.nextInt();
            if(num>random){
                System.out.println("猜大了");
            }else if(num<random){
                System.out.println("猜小了");
            }else{
                flag=true;
                break;
            }
        }while (count<3);

        //下结论
        if(flag){
            System.out.println("游戏结束，猜数字成功");
        }else{
            System.out.println("游戏结束，猜数字失败");
        }


    }
}
